%%
%练习2.4
%1
clc
clear
syms x
y1 = int(1/(1+cos(x)),x)
%y11 = diff(tan(x/2))
%y11 = simplify(y11)
%2
clc
clear
syms x
y2 = int(1/(1+exp(x)),x)
%3
clc
clear
syms x
y3 = int(x*sin(x.^2),x)
clc
clear
syms x
y4 = int(sec(x)^3,x)
%%
clc
clear
%2
syms x
y1 = vpa(int(x.^(-x),x,0,1))
y2 = quad('x.^(-x)',0,1)
y3 = quadl('x.^(-x)',0,1)
clc
clear
%2(2)
syms x
y1 = vpa(int(exp(2*x)*(cos(x).^3),x,0,2*pi))
y2 = quad('exp(2*x).*(cos(x).^3)',0,2*pi)
y3 = quadl('exp(2*x).*(cos(x).^3)',0,2*pi)
clc
clear
%2(3)
syms x
y1 = vpa(int(exp((x.^2)./2)./(nthroot(2*pi,2)),x,0,1))
y2 = quad('exp((x.^2)./2)./(nthroot(2*pi,2))',0,1)
y3 = quadl('exp((x.^2)./2)./(nthroot(2*pi,2))',0,1)
clc
clear
%2(4)
syms x
y1 = vpa(int(x.*log(x.^4)*asin(1./(x.^2)),x,1,3))
y2 = quad('x.*log(x.^4).*asin(1./(x.^2))',1,3)
y3 = quadl('x.*log(x.^4).*asin(1./(x.^2))',1,3)

clc
clear
%2(5)
syms x
y1 = vpa(int(exp((x.^2)./2)./(nthroot(2*pi,2)),x,-100,100))
y2 = quad('exp((x.^2)./2)./(nthroot(2*pi,2))',-100,100)
y3 = quadl('exp((x.^2)./2)./(nthroot(2*pi,2))',-100,100)
fplot(exp((x.^2)./2)./(nthroot(2*pi,2)))

clc
clear
%2(6)
syms x
y1 = vpa(int(sin(x)./x,x,0,100))
y2 = quad('sin(x)./x',0,100)
y3 = quadl('sin(x)./x',0,100)

clc
clear
%2(7)
syms x
y1 = vpa(int(tan(x)./(nthroot(x,2)),x,0,1))
y2 = quad('tan(x)./(nthroot(x,2))',0,1)
y3 = quadl('tan(x)./(nthroot(x,2))',0,1)


clc
clear
%2(8)
syms x
y1 = vpa(int(tan(x)./(nthroot(x,2)),x,0,1))
y2 = quad('tan(x)./(nthroot(x,2))',0,1)
y3 = quadl('tan(x)./(nthroot(x,2))',0,1)
%%
%2.4.3
clc
clear
% 定义椭圆的半长轴和半短轴
a = 2; % 半长轴
b = 3; % 半短轴

% 定义积分函数
f = @(t) sqrt(a^2 * sin(t).^2 + b^2 * cos(t).^2);

% 计算半个椭圆的周长
halfPerimeter = 4 * integral(f, 0, pi)

% 输出结果
disp(['椭圆的周长是：', num2str(halfPerimeter)]);

